package handlers

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

// Dashboard 处理仪表盘页面的请求
func Dashboard(c *gin.Context) {
	// 从上下文中获取用户名和角色
	username, exists := c.Get("username")
	if !exists {
		c.JSON(http.StatusInternalServerError, gin.H{"error": "无法获取用户名"})
		return
	}
	role, exists := c.Get("role")
	if !exists {
		c.JSON(http.StatusInternalServerError, gin.H{"error": "无法获取用户角色"})
		return
	}

	//// 渲染仪表盘页面
	//c.HTML(http.StatusOK, "dashboard.html", gin.H{
	//	"username": username,
	//	"role":     role,
	//})

	// 返回 JSON 数据
	c.JSON(http.StatusOK, gin.H{
		"username": username,
		"role":     role,
	})
}
